package Day08;

public class Day08 {

    public static void main(String[] args) {
        //最长连续子序列

        //路径dp
        import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
        public class Main {
            public static void main(String[] args) {
                Scanner in = new Scanner(System.in);
                int n = in.nextInt();
                int m = in.nextInt();
                char[][] arr = new char[n][];
                for(int i = 0; i < n; i++){
                    arr[i] = in.next().toCharArray();
                }
                int[][] dp = new int[n + 1][m + 1];
                for(int i = 1; i < dp.length; i++){
                    for(int j = 1; j < dp[i].length; j++){
                        dp[i][j] += Math.max(dp[i - 1][j], dp[i][j - 1]);
                        char tmp = arr[i - 1][j - 1];
                        if(tmp == 'l'){
                            dp[i][j] += 4;
                        }else if(tmp == 'o'){
                            dp[i][j] += 3;
                        }else if(tmp == 'v'){
                            dp[i][j] += 2;
                        }else if(tmp == 'e'){
                            dp[i][j] += 1;
                        }
                    }
                }
                System.out.println(dp[n][m]);
            }
        }
    }
}
